package guda.mrpc.example.server;

import guda.mrpc.core.RequestKey;
import guda.mrpc.core.config.ServerConfig;
import guda.mrpc.core.registry.impl.ZookeeperRegistry;
import guda.mrpc.core.serialize.impl.DefaultSerialize;
import guda.mrpc.core.server.Server;
import guda.mrpc.example.server.service.HelloService;
import guda.mrpc.example.server.service.HelloServiceImpl;

/**
 * Created by well on 17/5/24.
 */
public class ServerStartTest {


    public static void  main(String[] args){
        ServerConfig serverConfig = new ServerConfig();
        serverConfig.setAppId("jjk");
        serverConfig.setHost("127.0.0.1");
        serverConfig.setPort(5555);

        serverConfig.setObjectSerialize(new DefaultSerialize());

        RequestKey requestKey = new RequestKey(HelloService.class.getName());

        Server server = new Server();
        server.setServerConfig(serverConfig);
        ZookeeperRegistry zookeeperRegistry = new ZookeeperRegistry();
        zookeeperRegistry.connectToRegistryServer("127.0.0.1:2181");
        server.setServiceRegistry(zookeeperRegistry);
        server.registerService(requestKey, new HelloServiceImpl());

        server.startServer();


    }
}
